<div class="detail-view-container">
  <div class="container-bg"></div>
  <div class="detail">
    <div class="header">
      <a class="back-arrow" routerLinkActive="active" [routerLink]="['../']">
        <svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
          <path d="M0 0h24v24H0z" fill="none" />
          <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
        </svg>
      </a>
      <!-- <div mat-card-avatar [style.background]="'#c7b7dd'">{{testResultInfo.name| name2avatar}}</div> -->
      <div class="header-text" *ngIf="mode!='new'">
        <div class="header-name">{{testResultInfo.name}}</div>
        <div class="header-detail">{{testResultInfo.detail | delHtmlTag}}</div>
      </div>
      <div class="header-text" *ngIf="mode=='new'">
        <div class="header-name">新建缺陷</div>
      </div>
      <!-- <div class="header-text">
        <div class="header-name">{{testResultInfo.name?testResultInfo.name:'新建缺陷'}}</div>
        <div class="header-detail">{{testResultInfo.detail?(testResultInfo.detail|delHtmlTag):'缺陷描述'}}</div>
      </div> -->
    </div>
    <mat-card class="">
      <div class="dialog-content">
        <form action="" [formGroup]="testResultForm" (ngSubmit)="onSubmit('one')">
          <div class="detail-content">
            <mat-form-field>
              <input matInput placeholder="测试结果名称" [formControl]="name" [(ngModel)]="testResultInfo.name" name="name">
              <mat-error>{{formErrors.name}}</mat-error>
            </mat-form-field>

            <div class="editor">
              <span>缺陷描述</span>
              <quill-editor [formControl]="detail" [(ngModel)]="testResultInfo.detail" [modules]="modules"></quill-editor>
            </div>

            <mat-form-field>
              <mat-select placeholder="测试集" [formControl]="setId" [(ngModel)]="testResultInfo.setId" name="setId">
                <mat-option>未选择</mat-option>
                <mat-option *ngFor="let ts of searchSetList" [value]="ts.id" (click)="changeTestSet(ts.id)">
                  {{ts.name}}
                </mat-option>
              </mat-select>
              <mat-error>{{formErrors.setId}}</mat-error>
            </mat-form-field>

            <mat-form-field *ngIf="testResultInfo.setId">
              <mat-select placeholder="测试案例" [formControl]="caseId" [(ngModel)]="testResultInfo.caseId" name="caseId">
                <mat-option>未选择</mat-option>
                <mat-option *ngFor="let tc of searchCaseList" [value]="tc.id">
                  {{tc.name}} - {{tc.type}}
                </mat-option>
              </mat-select>
              <mat-error>{{formErrors.caseId}}</mat-error>
            </mat-form-field>

            <div class="editor">
              <span>实际输出</span>
              <quill-editor [formControl]="output" [(ngModel)]="testResultInfo.output" [modules]="modules"></quill-editor>
              <mat-error>{{formErrors.output}}</mat-error>
            </div>

            <mat-form-field>
              <mat-select placeholder="测试结果状态" [formControl]="status" [(ngModel)]="testResultInfo.status" name="status">
                <mat-option value="tofix" aria-selected="true">待修复</mat-option>
                <mat-option value="tocheck">待审核</mat-option>
                <mat-option value="close">通过测试</mat-option>
              </mat-select>
              <mat-error>{{formErrors.status}}</mat-error>
            </mat-form-field>

            <mat-form-field>
              <mat-select placeholder="优先级" [formControl]="level" [(ngModel)]="testResultInfo.level" name="level">
                <mat-option value="low">低</mat-option>
                <mat-option value="normal" aria-selected="true">中</mat-option>
                <mat-option value="high">高</mat-option>
              </mat-select>
            </mat-form-field>

            <mat-form-field *ngIf="testResultInfo.status!=='close'">
              <mat-select placeholder="严重程度" [formControl]="priority" [(ngModel)]="testResultInfo.priority" name="priority">
                <mat-option value="low">低</mat-option>
                <mat-option value="normal" aria-selected="true">中</mat-option>
                <mat-option value="high">高</mat-option>
              </mat-select>
            </mat-form-field>
          </div>

          <div class="detail-footer">
            <button mat-button (click)="cancel()">关闭</button>
            <button mat-button type="submit" [disabled]="!testResultForm?.valid">{{mode=='new'?'新建':'提交'}}</button>
            <button mat-button type="button" *ngIf="mode == 'new'" [disabled]="!testResultForm?.valid" (click)="onSubmit('again')">再次新建</button>
          </div>
        </form>
      </div>
    </mat-card>
  </div>
</div>

<toaster-container [toasterconfig]="toasterconfig"></toaster-container>